<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    var str = "id=1001; color=red; bgcolor=blue; width=1000; height=600";
    //以分号和空格进行分割
    var a = str.split("; ");
    var obj = {};
    console.log(a);
    for(var i = 0;i <a.length;i++){
      var b = a[i].split("=");
      console.log(b);
      for(var j=0;j<b.length;j++){
        obj[b[0]] = b[1];
      }
    }
    console.log(obj)
    console.log(obj.color);
  </script>
</body>
</html>